package test

import config.MyFile
import org.apache.commons.io.FileUtils
import scala.jdk.CollectionConverters._

object test extends MyFile {

  def main(args: Array[String]): Unit = {
    val l = "D:\\上海农科院大麦基因组\\Hordeum_vulgare_goldenpromise/Hordeum_vulgare_goldenpromise.GPv1.51.gff3".readLines.filter(!_.startsWith("#")).map(_.split("\t")).
      filter(_ (2) == "gene").map(x => x.last.split(";").find(_.startsWith("ID=")).get.drop(8) -> x.mkString("\t"))
    val l2 = "D:\\上海农科院大麦基因组\\Hordeum_vulgare_goldenpromise/Hordeum_vulgare_goldenpromise.GPv1.cds.all.fa".readFileToString.split(">").tail.map { x =>
      x.split("\n").head.split(" ").find(_.startsWith("gene:")).get.drop(5)
    }.distinct

    println(l.map(_._1).diff(l2).length)

    println(l.head)

    println(l2.length)

    val row = l.filter(x => l2.indexOf(x._1) != -1).map(_._2)

    println(row.length)

    FileUtils.writeLines("D:\\上海农科院大麦基因组/Hordeum_vulgare_goldenpromise/Hordeum_vulgare_goldenpromise.gff".toFile, row.asJava)

  }

  def x = {
    val l = "D:\\上海农科院大麦基因组/Hordeum_vulgare.cds".readFileToString.split(">").tail.map { x =>
      x.split("\n").head.split(" ").last.drop(10)
    }.distinct
    l.foreach(println)
    println(l.length)
  }
}
